package cn.wolfcode.luowowo2.search.query;

import cn.wolfcode.luowowo2.common.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

/**
 * Created by Albert on 2019/7/15.
 */
@Getter
@Setter
public class SearchQueryObject extends QueryObject {
    public static final int CONDITION_TYPE_ABROAD = 0;
    public static final int CONDITION_TYPE_INNER = 1;
    public static final int CONDITION_TYPE_THEME = 2;

    private String orderBy = "viewnum";
    private int type= -1; //省份,国家,主题
    private int typeValue= -1; //条件值

    private Long destId = -1L;

    private String keyword;

    public Pageable getPageable(){
        PageRequest pageable = PageRequest.of(getCurrentPage() - 1,getPageSize(), Sort.Direction.DESC,orderBy);
        return pageable;
    }
    public Pageable getPageableWithOutSort(){
        PageRequest pageable = PageRequest.of(getCurrentPage() - 1,getPageSize());
        return pageable;
    }
}
